$(function() {
	$('#vue_vm_list div').hide();
});

var account = {
	id: '',
	staffId: '',
	account: '',
	password: '',
	status: '',
	createTime: '',
	updateTime: '',
	createId: '',
	updateId: '',
	remark: '',
};

var view = {
	data: account
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function register() {
	view.data.account = $('#account').val();
	view.data.status = (view.data.status==''? 0: parseInt(view.data.status));

	save_basic(path+'/account/register', {account:view.data}, function() {
		alert('账号开通成功');
	});
}

function findStaffInfo() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();
	var searchVal = $('#searchVal').val();
	
	openWaiting('正在查找');
	
	find_basic(path+'/staffInfo/find', searchVal, function(response) {
		view.data.staffId = response.data[0].staffId;
		$('#account').val(response.data[0].phoneNumber);
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			}
		});
		
		$('#vue_vm_list div').show();
		
		closeWaiting();
	});
}

function login() {
	view.data.status = (view.data.status==''? 0: parseInt(view.data.status));
	
	handle_basic(path+'/account/login', {account:view.data}, function(response) {
		var loginedUser = {};
		loginedUser.staffId = response.data[0].staffInfoForm.staffId;
		loginedUser.staffName = response.data[0].staffInfoForm.name;
		loginedUser.personType = response.data[0].staffInfoForm.personType;
		loginedUser.personTypeName = response.data[0].staffInfoForm.personTypeName;
		loginedUser.subjectRoomId = response.data[0].staffInfoForm.subjectRoomId;
		loginedUser.subjectRoomName = response.data[0].staffInfoForm.subjectRoomName;
		loginedUser.departmentId = response.data[0].staffInfoForm.departmentId;
		loginedUser.departmentName = response.data[0].staffInfoForm.departmentName;
		loginedUser.dutyId = response.data[0].staffInfoForm.dutyId;
		loginedUser.dutyName = response.data[0].staffInfoForm.dutyName;
		loginedUser.typeOfDuty = response.data[0].staffInfoForm.typeOfDuty;
		
		setLoginedUser(loginedUser);
		window.location.href = 'index.html';
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/account/deleteBatch');
}
